package com.dapeng.cleardatabackend.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * 关系表
 * @author dapeng
 * @TableName relation
 */
@TableName(value ="relation")
@Data
public class Relation implements Serializable {
    /**
     * id
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 前键用户定义id
     */
    @ApiModelProperty(value = "前键用户定义id")
    private String startNodeId;

    /**
     * 关系
     */
    @ApiModelProperty(value = "关系")
    private String relationText;

    /**
     * 后键用户定义id
     */
    @ApiModelProperty(value = "后键用户定义id")
    private String endNodeId;

    /**
     * 图谱id
     */
    @TableField(value = "graphId")
    private Long graphId;

    /**
     * 创建时间
     */
    @TableField(value = "createTime")
    private Date createTime;

    /**
     * 更新时间
     */
    @TableField(value = "updateTime")
    private Date updateTime;

    /**
     * 是否删除
     */
    @TableField(value = "isDelete")
    @TableLogic
    private Integer isDelete;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Relation relation = (Relation) o;
        return Objects.equals(startNodeId, relation.startNodeId) &&
                Objects.equals(relationText, relation.relationText) &&
                Objects.equals(endNodeId, relation.endNodeId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(startNodeId, relationText, endNodeId);
    }

}